<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">

<xsl:for-each select="topology/nodes/node">

<xsl:variable name="ID"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="temp"><xsl:value-of select="software_configuration/@template"/></xsl:variable>
<xsl:variable name="MAC"><xsl:value-of select="network_interfaces/interface/@MAC"/></xsl:variable>
<xsl:variable name="ETH"><xsl:value-of select="network_interfaces/interface/@name"/></xsl:variable>
<xsl:variable name="IP"><xsl:value-of select="network_interfaces/interface/ip/@address"/></xsl:variable>

<xsl:if test="$temp='debian5_omfAgr'">

update testbeds set control_ip= '<xsl:value-of select="$IP"/>@' where id ='1';
update testbeds set oml_url= 'tcp:<xsl:value-of select="$IP"/>:3003' where id ='1';

</xsl:if>

<xsl:if test="$temp='debian5_omfNode'">

insert into devices values('<xsl:value-of select="$ID"/>','1','1','1','','<xsl:value-of select="$MAC"/>','<xsl:value-of select="$ETH"/>');
insert into locations values('<xsl:value-of select="$ID"/>','1','<xsl:value-of select="$ID"/>','1','NULL','NULL','NULL','1','NULL');
insert into nodes values('<xsl:value-of select="$ID"/>','1','1','1','<xsl:value-of select="$ID"/>','<xsl:value-of select="$IP"/>','1');
update testbeds set y_max= <xsl:value-of select="$ID"/> where id = 1;
</xsl:if>

</xsl:for-each>

</xsl:template>
</xsl:stylesheet>


